package com.rocching.easychat.core;

import android.content.Context;
import android.text.Spannable;
import android.text.SpannableString;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.rocching.easychat.R;
import com.rocching.easychat.model.AppConst;

import java.util.List;

import io.rong.imkit.conversation.messgelist.provider.BaseMessageItemProvider;
import io.rong.imkit.model.UiMessage;
import io.rong.imkit.subconversationlist.RongSubConversationListActivity;
import io.rong.imkit.widget.adapter.IViewProviderListener;
import io.rong.imkit.widget.adapter.ViewHolder;
import io.rong.imlib.model.MessageContent;
import io.rong.message.ContactNotificationMessage;

public class ContactNotificationMessageProvider extends BaseMessageItemProvider<ContactNotificationMessage> {
    @Override
    protected ViewHolder onCreateMessageContentViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.rc_item_information_notification_message, null);
        return new ViewHolder(view.getContext(), view);
    }

    @Override
    protected void bindMessageContentViewHolder(ViewHolder holder, ViewHolder parentHolder, ContactNotificationMessage content, UiMessage uiMessage, int position, List<UiMessage> list, IViewProviderListener<UiMessage> listener) {
        if (content != null) {
            holder.setText(R.id.rc_msg, content.getMessage());
        }
    }

    @Override
    protected boolean onItemClick(ViewHolder holder, ContactNotificationMessage contactNotificationMessage, UiMessage uiMessage, int position, List<UiMessage> list, IViewProviderListener<UiMessage> listener) {
        return false;
    }

    @Override
    protected boolean isMessageViewType(MessageContent messageContent) {
        return messageContent instanceof ContactNotificationMessage;
    }

    @Override
    public Spannable getSummarySpannable(Context context, ContactNotificationMessage content) {
        if (content != null) {
            return new SpannableString(content.getMessage());
        }
        return null;
    }
}
